package com.work.controller;

import com.work.annotation.CzkAutoWired;
import com.work.annotation.CzkController;
import com.work.annotation.CzkRequestMapping;
import com.work.annotation.CzkRequestParam;
import com.work.service.Student;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 控制层
 * @Author:ChenZhangKun
 * @Date: 2020/12/3 20:08
 */
@CzkController
@CzkRequestMapping("/student")
public class StudentController {
    @CzkAutoWired("studentImpl")
    private Student student;
    @CzkRequestMapping("/czk.do")
    public void queryInfo(HttpServletRequest request, HttpServletResponse response, @CzkRequestParam("name") String name){
        try {
            // 设置响应头
            response.setContentType("application/json;charset=utf-8");
            // 获取输出
            PrintWriter writer = response.getWriter();
            String hello = student.hello();
            writer.write(hello);
        }catch (IOException ex){
            ex.printStackTrace();
        }
    }
}
